"""
  You will need this lib: http://code.google.com/p/pygooglevoice/ + a 
  Google Voice and GMail account in order to send SMS and emails.
  
  Google Voice lib fails with Python 3.1.2

  Happy birthday Simon!!
"""
from googlevoice import Voice
from email.mime.text import MIMEText
import smtplib
import datetime
import time

def send_shits(msg):
  gmail_login_email = "a@a.com"
  gmail_login_pass = "xxxxxx"
  gmail_smtp_server = "smtp.gmail.com:587"

  msg_subject = "Arrete de gosser apres mon cell pi fais dla mec"
  simon_cell_nb = "xxxxx"
  simon_mail = "a@a.com"

  # Send SMS with Google Voice
  voice  = Voice()
  voice.login(gmail_login_email, gmail_login_pass)
  voice.send_sms(simon_cell_nb, msg)
  voice.logout()

  # Mail @ gmail server
  mail = MIMEText(msg)
  mail['Subject'] = msg_subject
  mail['From'] = gmail_login_email
  mail['To'] = simon_mail
  server = smtplib.SMTP(gmail_smtp_server)
  server.starttls()
  server.login(gmail_login_email, gmail_login_pass)
  server.sendmail(gmail_login_email, simon_mail, mail.as_string())
  server.quit()

i = 0
while ( i <= 24):
  if ( i == 24):
    msg = "C'eeeeeeest finiiii! A l'annee prochaine"
  else:
    now = datetime.datetime.now()
    begin = datetime.datetime(now.year, now.month, now.day, now.hour, now.minute, now.second)
    end  = datetime.datetime(now.year, now.month, now.day + 1, 0, 0, 0)
    difference = end - begin
    msg = "Bonne fete simon! Il reste " + str(difference) + " avant la fin. T'es mon best men!"

  send_shits(msg)
  i = i + 1

  # Send every hours
  time.sleep(3600)
